package com.aj.http.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;

import com.aj.databases.entry.FamilyZoneInfo;

@SuppressLint("NewApi")
public class GetAlbumPhotoResponse extends BaseRespond {

	List<FamilyZoneInfo> albumPhotoInfoList = new ArrayList<FamilyZoneInfo>();

	public GetAlbumPhotoResponse(JSONObject json) {
		super(json);
		if (common != null && common.getResult() != null) {
			try {
				if (common.getResult() == null) {
					return;
				}
				if (!common.getResult().isNull("list")) {
					JSONArray jsonArray = common.getResult().getJSONArray(
							"list");
					FamilyZoneInfo albumPhotoInfo;
					for (int i = 0; i < jsonArray.length(); i++) {
						albumPhotoInfo = new FamilyZoneInfo();
						albumPhotoInfo.setZoneId(jsonArray.getJSONObject(i)
								.getString("albumId"));
						albumPhotoInfo.setZoneName(jsonArray.getJSONObject(i)
								.getString("albumName"));
						albumPhotoInfo.setZoneUrl(jsonArray.getJSONObject(i)
								.getString("albumUrl"));
						if (!jsonArray.getJSONObject(i).isNull("photoNumber")) {
							albumPhotoInfo.setPhotoNumber(jsonArray
									.getJSONObject(i).getInt("photoNumber"));
						} else {
							albumPhotoInfo.setPhotoNumber(0);
						}
						albumPhotoInfoList.add(albumPhotoInfo);
					}
				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}

	public List<FamilyZoneInfo> getAlbumPhotoInfoList() {
		return albumPhotoInfoList;
	}

	public void setAlbumPhotoInfoList(List<FamilyZoneInfo> albumPhotoInfoList) {
		this.albumPhotoInfoList = albumPhotoInfoList;
	}

}
